from pathlib import Path

import pandas as pd

__data__: dict[dict[str, str]] = {
    "default_history": {
        "path": "default_history.pkl",
        "type": "pkl",
        "notes": "本数据取自于银行历史数据，覆盖了历史多年的客户违约统计数据"
    }
}


def load_data(name: str) -> pd.DataFrame:
    if name not in __data__:
        raise ValueError(f"数据{name}不存在")

    filepath: Path = Path(__file__).parent.joinpath(__data__[name]["path"])
    if not filepath.exists():
        raise FileNotFoundError(f"数据文件{filepath}不存在")

    if __data__[name]["type"] == "pkl":
        return pd.read_pickle(filepath)
